<template>
  <el-select v-model="value" placeholder="请选择诊断" @change="optionChange">
    <el-option
      v-for="item in hisDiagnosisList"
      :key="item.icdCode"
      :label="item.icdName"
      :value="item.icdCode"
    >
      <span style="float: left">{{ item.icdName }}</span>
      <span
        style="
          float: right;
        "
      >
        ({{ item.icdCode }})
      </span>
    </el-option>
  </el-select>
</template>

<script lang="ts" setup>

const emit = defineEmits(['optionChange'])
// 通过父组件注入的方法获取hisDiagnosisList
const hisDiagnosisList = toRaw(inject('getHisDiagnosisList', null)?.value)
const value = ref('')

function optionChange(icdCode: string) {
  const index = hisDiagnosisList.findIndex(it => it.icdCode === icdCode);
  if (index > -1) {
    emit('optionChange', hisDiagnosisList[index]);
  }
}

</script>


<style scoped>

</style>
